package home

import (
	"encoding/json"
	"io/ioutil"
)

type Monster struct {
	Name  string
	Age   byte
	Skill string
}

func (this *Monster) Store() bool {
	data, err := json.Marshal(this)
	if err != nil || ioutil.WriteFile("store.dat", data, 0666) != nil {
		return false
	}
	return true
}

func (this *Monster) ReStore() bool {
	data, err := ioutil.ReadFile("store.dat")
	if err != nil || json.Unmarshal(data, this) != nil {
		return false
	}
	return true
}
